package com.yc.sakuralxm.uestcscanning.tools

import android.util.Log

/**
 * @author realicing@sina.com
 * @ClassName: L
 * @Description: 封装的打印类
 * @date 2016-5-7 上午159:26:08
 */
object L {

    private val TAG = "-----sakura"
    var LOG_DEBUG = false
    fun w(msg: String) {
        if (LOG_DEBUG) {
            Log.w(TAG, "---zzz---" + msg)
        }
    }

    fun e(msg: String) {
        Log.e(TAG, "---zzz---" + buildMessage(msg))
    }

    fun e(tag: String, msg: String) {
        Log.e(TAG, tag + "---zzz---" + msg)
    }

    fun i(msg: String) {
        if (LOG_DEBUG) {
            Log.i(TAG, "---zzz---" + buildMessage(msg))
        }
    }

    fun i(tag: String, msg: String) {
        if (LOG_DEBUG) {
            Log.i(TAG, tag + "---zzz---" + msg)
        }
    }

    fun v(msg: String) {
        if (LOG_DEBUG) {
            Log.v(TAG, "---zzz---" + msg)
        }
    }

    fun v(tag: String, msg: String) {
        if (LOG_DEBUG) {
            Log.v(TAG, tag + "---zzz---" + msg)
        }
    }

    fun d(msg: String) {
        if (LOG_DEBUG) {
            Log.d(TAG, "---zzz---" + msg)
        }
    }

    fun d(tag: String, msg: String) {
        if (LOG_DEBUG) {
            Log.d(TAG, tag + "---zzz---" + buildMessage(msg))
        }
    }

    internal fun buildMessage(msg: String): String {
        val caller = Throwable().fillInStackTrace().stackTrace[2]
        return StringBuilder().append(caller.className).append(".").append(caller.methodName).append("(): ").append(msg).toString()
    }
}
